<template>
	<div class="admin_home">
			<el-dialog title="登录" :visible.sync="dialogFormVisible" width="500px" style="text-align: center;">
			  <el-form v-model="form">
			    <el-form-item label="账号" :label-width="formLabelWidth">
			      <el-input v-model="form.username" autocomplete="off"></el-input>
			    </el-form-item>
						 <el-form-item label="密码" :label-width="formLabelWidth">
						   <el-input v-model="form.password"  autocomplete="off"></el-input>
						 </el-form-item>
			  </el-form>
			  <div slot="footer" class="dialog-footer">
			    <el-button type="primary" @click="login()">确 定</el-button>
			  </div>
			</el-dialog>
	</div>
</template>

<script>
	export default {
		name:'AdminLogin',
		data(){
			return{
				dialogFormVisible: true,
				formLabelWidth: '120px',
				form:{
					 username:'',
				     password:'',
				}
			}
		},
		methods:{
			login(){
				this.dialogFormVisible = false;
				this.$postkv('/api/login',this.form).then((resp)=>{
					let token = resp.data.data.token;
					window.localStorage.setItem("token",token);
					this.$get('/api/user/info').then((resp)=>{
						
					})
					this.$message({
						message:resp.data.msg,
						type:'success'
					})
				})
				this.form = {};
			}
		}
	}
</script>

<style scoped>
	.admin_home{
		background-color: aqua;
	}
</style>
